package com.x.crm.controller;


import com.alibaba.fastjson.JSON;
import com.x.crm.model.*;
import com.x.crm.payload.IntentionMsg;
import com.x.crm.rpc.*;
import com.x.crm.util.Constant;
import com.x.erp.model.Car;

import com.x.erp.model.User;
import com.x.erp.rpc.CarRpcService;
import com.x.erp.rpc.UserRpcService;
import com.x.framework.controller.BaseController;
import com.x.framework.controller.ResultCode;
import com.x.framework.controller.ResultModel;
import com.alibaba.dubbo.config.annotation.Reference;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * Created by Administrator on 2018/2/2.
 */
@RestController
@RequestMapping("/customer")
public class FollowInfoController extends BaseController {

	@Reference
	private CustomerShopRpcService customerShopRpcService;
	@Reference
	private CustomerRpcService customerRpcService;
	@Reference
	private IntentionRpcService intentionRpcService;
	@Reference
	private IntentionModelRpcService intentionModelRpcService;
	@Reference
	private UserRpcService userRpcService;
	@Reference
	private FollowRpcService followRpcService;
	@Reference
	private CarRpcService carRpcService;


	/**
	 * 查询客户信息
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/list", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getCustomerList(CustomerShop customerShop, Customer customer) {
		if (StringUtils.isEmpty(customerShop.getShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "店铺ID不能为空");
		}
		customerShop.setCustomer(customer);
		List<CustomerShop> customerShopList = customerShopRpcService.selectCustomerShopList(customerShop);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", customerShopList);
	}

	/**
	 * 查询客户数量
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/customerNum", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getCustomerNum(CustomerShop customerShop, Customer customer) {

		if (StringUtils.isEmpty(customerShop.getShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "店铺ID不能为空");
		}
		customerShop.setCustomer(customer);
		int res = customerShopRpcService.selectCustomerShopNum(customerShop);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", res);
	}

	/**
	 * 插入客户信息
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/insertCustomer", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel insertCustomer(CustomerShop customerShop, Customer customer) {

		if (StringUtils.isEmpty(customerShop.getShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "店铺ID不能为空");
		}
		if (StringUtils.isEmpty(customer.getCustomerPhone())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "手机号不能为空");
		}
		customerShop.setFollowState(0); //待分配
		Customer customer1 = new Customer();
		customer1.setCustomerPhone(customer.getCustomerPhone());
		List<Customer> customers = customerRpcService.selectCustomerList(customer1);
		if (customers != null && !customers.isEmpty()) {
			customer.setCustomerId(customers.get(0).getCustomerId());
			customerRpcService.updateCustomer(customer);
		} else {
			customer = customerRpcService.insertCustomer(customer);
		}
		CustomerShop customerShop1 = new CustomerShop();
		customerShop1.setCustomerId(customer.getCustomerId());
		customerShop1.setShopId(customerShop.getShopId());
		List<CustomerShop> customerShops = customerShopRpcService.selectCustomerShopList(customerShop1);
		customerShop.setCustomerId(customer.getCustomerId());
		if (customerShops != null && !customerShops.isEmpty()) {
			customerShop.setCustomerShopId(customerShops.get(0).getCustomerShopId());
			customerShopRpcService.updateCustomerShop(customerShop);
		} else {
			customerShop.setFollowState(0); //新增待分配
			customerShop = customerShopRpcService.insertCustomerShop(customerShop);
		}
		customerShop.setCustomer(customer);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "插入成功", customerShop);
	}

	/**
	 * 更新客户信息
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/updateCustomer", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel updateCustomer(CustomerShop customerShop, Customer customer) {

		if (StringUtils.isEmpty(customerShop.getShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "店铺ID不能为空");
		}
		if (StringUtils.isEmpty(customerShop.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "客户ID不能为空");
		}
		customerRpcService.updateCustomer(customer);
		customerShopRpcService.updateCustomerShop(customerShop);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "更新成功");
	}

	/**
	 * 查询客户下的意向列表
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/intentionList", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getCustomerList(Intention intention) {

		if (StringUtils.isEmpty(intention.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "客户Id不能为空");
		}
		List<Intention> intentionList = intentionRpcService.selectIntentionInfoList(intention);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", intentionList);
	}

	/**
	 * 查询客户下的意向列表
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/intentionNum", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getIntentionNum(Intention intention) {

		if (StringUtils.isEmpty(intention.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "客户Id不能为空");
		}
		int res = intentionRpcService.selectIntentionNum(intention);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", res);
	}


	/**
	 * 插入意向列表
	 *
	 * @param
	 * @return
	 */
//	
	@RequestMapping(value = "/insertIntention", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel insertIntention(Intention intention, String modelList) {

		if (StringUtils.isEmpty(intention.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "客户Id不能为空");
		}
		if (StringUtils.isNotEmpty(modelList)) {
			List<IntentionModel> models = JSON.parseArray(modelList, IntentionModel.class);
			intention.setIntentionModelList(models);
		}
		Intention res = intentionRpcService.insertWxIntentionInfo(intention, null);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "插入成功", res);
	}

	/**
	 * 更新意向
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/updateIntention", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel updateIntention(Intention intention, String modelList) {

		if (StringUtils.isEmpty(intention.getIntentionId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "意向不能为空");
		}
		if (StringUtils.isNotEmpty(modelList)) {
			List<IntentionModel> models = JSON.parseArray(modelList, IntentionModel.class);
			intention.setIntentionModelList(models);
		}
		int res = intentionRpcService.updateIntentionInfo(intention);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "更新成功", res);
	}

	/**
	 * 查询意向车辆列表
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/getIntentionModelList", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getIntentionModelList(IntentionModel intentionModel) {

		if (StringUtils.isEmpty(intentionModel.getIntentionId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "意向Id不能空");
		}
		List<IntentionModel> intentionModelList = intentionModelRpcService.selectIntentionModelList(intentionModel);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", intentionModelList);
	}


	@RequestMapping(value = "/getIntentionModelNum", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getIntentionModelNum(IntentionModel intentionModel) {

		if (StringUtils.isEmpty(intentionModel.getIntentionId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "意向Id不能空");
		}
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功",  intentionModelRpcService.selectIntentionModelNum(intentionModel));
	}

	/**
	 * 查询分配人
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/queryUserList", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getUserList(User user) {
		if (StringUtils.isEmpty(user.getShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "店铺ID不能为空");
		}
		user.setUserState(1);
		Map<String, Object> userInfo = null;
		List<Map<String, Object>> userList = new ArrayList<>();
		List<User> usersInShop = userRpcService.selectUserList(user);
		for(User model:usersInShop){
            CustomerShop customerShop = new CustomerShop();
            customerShop.setFollowerId(model.getUserId());
	        customerShop.setMarketId(model.getMarketId());
	        customerShop.setShopId(model.getShopId());
	        customerShop.setFollowState(Constant.CUSTOMER_FOLLOWED);
	        int customerNum = customerShopRpcService.selectCustomerShopNum(customerShop);
			userInfo = new HashMap<>();
			userInfo.put("userId",model.getUserId());
	        userInfo.put("userName",model.getUserName());
	        userInfo.put("userMobile", model.getUserMobile());
	        userInfo.put("customerNum", customerNum);
			userList.add(userInfo);
		}
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", userList);
	}

	/**
	 * 分配给客户
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/allocate", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getUserList(CustomerShop customerShop) {

		if (StringUtils.isEmpty(customerShop.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "客户ID不能为空");
		}
		if (StringUtils.isEmpty(customerShop.getFollowerId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "分配人不能为空");
		}
		if (customerShop.getNextFollowDatetime() == null) {
			return new ResultModel(ResultCode.RESULT_FAIL, "下次跟进时间不能为空");
		}
		customerShop.setFollowState(1); //待处理
		int res = customerShopRpcService.updateCustomerShop(customerShop);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "更新成功", res);
	}


	/**
	 * 客戶意向車輛列表
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/getCarModeList", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getCarModeList(IntentionModel intentionModel, CustomerShop customerShop) {

		if (StringUtils.isEmpty(customerShop.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "客戶不能為空");
		}
		List<IntentionModel> intentionModelList = intentionModelRpcService.selectModelList(intentionModel, customerShop);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", intentionModelList);
	}

	/**
	 * 提交客户意向跟进
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/insertFollowInfo", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel insertFollowInfo(Follow follow, String carId) {

		if (StringUtils.isEmpty(follow.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "客戶ID不能為空");
		}
		CustomerShop customerShop = new CustomerShop();
		customerShop.setCustomerShopId(follow.getCustomerShopId());
		CustomerShop customerShopInfo = customerShopRpcService.selectCustomerShopList(customerShop).get(0);
		switch (customerShopInfo.getFollowState()) {
			case 0:
				return new ResultModel(ResultCode.RESULT_FAIL, "待分配的意向不能进行跟进");
			case 30:
				return new ResultModel(ResultCode.RESULT_FAIL, "战败的意向不能进行跟进");
			case 40:
				return new ResultModel(ResultCode.RESULT_FAIL, "失效的意向不能进行跟进");
			case 50:
				return new ResultModel(ResultCode.RESULT_FAIL, "已成交的意向不能进行跟进");
		}

		Car carInfo = new Car();
		if (StringUtils.isNotEmpty(carId)) {
			carInfo.setCarId(carId);
			carInfo = carRpcService.selectCar(carInfo);
			if (carInfo == null) {
				return new ResultModel(ResultCode.RESULT_FAIL, "车辆ID错误");
			}
		}
		follow.setFixtureVIN(carInfo.getCarVin());
		follow.setFixtureCar(carInfo.getCarTitle());
		Follow followInfo = followRpcService.insertFollow(follow);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "提交成功", followInfo);
	}


	/**
	 * 跟进历史接口
	 *
	 * @param
	 * @return
	 */
	@RequestMapping(value = "/followHistory", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel followHistoryList(Follow follow) {

		if (StringUtils.isEmpty(follow.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "客戶ID不能為空");
		}
		List<Follow> followHistoryList = followRpcService.selectFollowList(follow);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "提交成功", followHistoryList);
	}


	/**
	 * 客户成交车辆列表接口
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/fixtureCarList", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel fixtureCarList(Intention intention) {

		if (StringUtils.isEmpty(intention.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "客户ID不能为空");
		}
		intention.setIntentionState(50); //查找成交的车辆
		List<Intention> fixtureCarList = intentionRpcService.selectIntentionInfoList(intention);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", fixtureCarList);
	}

	/**
	 * 微信询价详情
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/insertWxInquiry", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel insertWxInquiry(Intention intention, IntentionModel intentionModel) {

		if (StringUtils.isEmpty(intention.getCustomerMobile())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "手机号不能为空");
		}
		if (StringUtils.isEmpty(intention.getMarketId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "市场信息不为空");
		}
		if (StringUtils.isEmpty(intention.getShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "店铺信息不能为空");
		}
		if (StringUtils.isEmpty(intentionModel.getCarId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "车辆ID不能为空");
		}
		if (StringUtils.isEmpty(intention.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "customerShopID不能为空");
		}
		CustomerShop customerShop = new CustomerShop();
		customerShop.setCustomerShopId(intention.getCustomerShopId());
		List<CustomerShop> customers = customerShopRpcService.selectCustomerShopList(customerShop);
		if (customers == null || customers.isEmpty()) {
			return new ResultModel(ResultCode.RESULT_FAIL, "customerShopID错误！");
		}
		customerShop = customers.get(0);
		Car car = new Car();
		car.setCarId(intentionModel.getCarId());
		car = carRpcService.selectCar(car);
		if (car == null) {
			return new ResultModel(ResultCode.RESULT_FAIL, "车辆ID错误！");
		}
		List<Intention> intentionList = intentionRpcService.selectIntentionInfoList(intention);
		if (intentionList.size() > 0) {
			for (Intention model : intentionList) {
				intentionModel.setIntentionId(model.getIntentionId());
				List<IntentionModel> intentionModelList = intentionModelRpcService.selectIntentionModelList(intentionModel);
				if (intentionModelList.size() != 0) {
					return new ResultModel(ResultCode.RESULT_FAIL, "已经存在此线索");
				}
			}
		}
//		customerShop.setFollowState(0);
		if (customerShop.getFollowState() == 2 && customerShop.getFollowerId() != null){
			intention.setFollowerId(customerShop.getFollowerId());
			intention.setFollowerName(customerShop.getFollowerName());
			intention.setIntentionState(Constant.INTENTION_DGJ);
			intention.setOpportunityState(Constant.OPPORTUNITY_YCL);
		}else{
			intention.setIntentionState(Constant.INTENTION_DFP);
			intention.setOpportunityState(Constant.OPPORTUNITY_DCL);
		}
		intention.setIntentionType(1);//购买
		intention.setIsOpportunity(1);
		intention.setGetTime(this.getDate(0));
		intention.setCreateTime(this.getDate(0));
		intention.setUpdateTime(this.getDate(0));
		intention.setIntentionChannelId("18080610455235661826450666957235");
		intention.setIntentionChannelName("微店-询底价（大屏）");
		intention.setCustomerContactName("微店询价客户");
		List<IntentionModel> intentionModelList = new ArrayList<>();
		intentionModelList.add(intentionModel);
		intention.setIntentionModelList(intentionModelList);
		String carId = intentionModel.getCarId();
		String mobile = intention.getCustomerMobile();
		String carTitle = car.getCarTitle();
		String date = getDate(getDate(0), "yyyy-MM-dd HH:mm:ss");
		User user = new User();
		user.setShopId(car.getShopId());
		List<User> users = userRpcService.selectUserList(user);
		Set<String> wxOpenIds = new HashSet<>();
		if (users != null && users.size() > 0) {
			for (User shopUser : users) {
				if (StringUtils.isNotEmpty(shopUser.getWxOpenId())) {
					wxOpenIds.add(shopUser.getWxOpenId());
				}
			}
		}
		Customer customer = customerShop.getCustomer();
		IntentionMsg intentionMsg = new IntentionMsg(carId, car.getShopId(), car.getMarketId(), mobile, StringUtils.isNotEmpty(customer.getCustomerName()) ? customer.getCustomerName() : customer.getCustomerNickname(), carTitle, date, wxOpenIds);
		intentionRpcService.insertWxIntentionInfo(intention, intentionMsg);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "插入成功！");
	}


	/**
	 * 微信根据CARID查询客户
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/getCustomerByCar", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getCustomerByCar(IntentionModel intentionModel, Intention intention) {

		if (StringUtils.isEmpty(intention.getShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "店铺ID不能为空");
		}
		if (StringUtils.isEmpty(intention.getMarketId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "市场ID不能为空");
		}
		intentionModel.setIntention(intention);
		List<Map<String, Object>> customerList = new ArrayList<>();
		setCustomerInfo(customerList, intentionModel);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", customerList);
	}
//
//

	/**
	 * 微信根据相似价格查询客户
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/getCustomerSimilarPrice", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getCustomerSimilarPrice(Car car) {

		if (StringUtils.isEmpty(car.getShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "店铺ID不能为空");
		}
		if (StringUtils.isEmpty(car.getMarketId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "市场ID不能为空");
		}
		if (StringUtils.isEmpty(car.getCarId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "车辆ID");
		}
		List<Map<String, Object>> customerList = new ArrayList<>();
		List<Car> carList = carRpcService.selectSimilarPriceCar(car);
		for (Car model : carList) {
			IntentionModel intentionModel = new IntentionModel();
			intentionModel.setCarId(model.getCarId());
			Intention intention = new Intention();
			intentionModel.setIntention(intention);
			setCustomerInfo(customerList, intentionModel);
		}
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", customerList);
	}
//
//

	/**
	 * 查询客户详情偏好喜爱
	 *
	 * @param
	 * @return
	 */
	
	@RequestMapping(value = "/getCustomerInfo", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel getCustomerInfo(CustomerShop customerShop) {
		if (StringUtils.isEmpty(customerShop.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "客户Id不能为空");
		}
		Intention intention = new Intention();
		intention.setCustomerShopId(customerShop.getCustomerShopId());
		IntentionModel intentionModel = new IntentionModel();
		intentionModel.setIntention(intention);
		List<IntentionModel> intentionModelList = intentionModelRpcService.selectIntentionCustomerList(intentionModel);
		List<Car> carInfoList = new ArrayList<>();
		for (IntentionModel model : intentionModelList) {
			Car car = new Car();
			car.setCarId(model.getCarId());
			carInfoList.add(car);
		}
		Car car = new Car();
		List<Map<String, Object>> carAgeList = carRpcService.selectStorageCarAgeRank(car, null, null, carInfoList);
		List<Map<String, Object>> carPriceList = carRpcService.selectStoragePriceRank(car, null, null, carInfoList);
		List<Map<String, Object>> carSeriesList = carRpcService.selectStorageSeriesRank(car, null, null, carInfoList);
		Map<String, Object> carRadarList = carRpcService.selectCarRadarInfo(car, null, null, carInfoList);
		Map<String, Object> customerInfo = new HashMap<>();
		Map<String, Object> intentionInfo = new HashMap<>();
		IntentionModel resInfo = intentionModelList.get(0);
		Intention getIntentionInfo = resInfo.getIntention();
		CustomerShop getCustomerInfo = getIntentionInfo.getCustomerShop();
		Customer getCustomer = getCustomerInfo.getCustomer();
		customerInfo.put("customerNickName", getCustomer.getCustomerNickname());
		customerInfo.put("customerHeadImage", getCustomer.getCustomerHeadImage());
		customerInfo.put("customerMobile", getIntentionInfo.getCustomerMobile());
		customerInfo.put("customerId", getCustomer.getCustomerId());
		customerInfo.put("customerRemark", getCustomerInfo.getCustomerRemark());
		customerInfo.put("createTime", getIntentionInfo.getCreateTime());
		intentionInfo.put("ageList", carAgeList);
		intentionInfo.put("priceList", carPriceList);
		intentionInfo.put("seriesList", carSeriesList);
		intentionInfo.put("carRadarList", carRadarList);
		customerInfo.put("intentionInfo", intentionInfo);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", customerInfo);
	}


	/**
	 * 修改客户备注
	 *
	 * @param
	 * @return
	 */

	
	@RequestMapping(value = "/updateCustomerRemark", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel updateCustomerRemark(CustomerShop customerShop) {

		if (StringUtils.isEmpty(customerShop.getCustomerShopId())) {
			return new ResultModel(ResultCode.RESULT_FAIL, "客户Id不能为空");
		}
		int res = customerShopRpcService.updateCustomerShop(customerShop);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "更新成功", res);
	}


	private void setCustomerInfo(List<Map<String, Object>> customerList, IntentionModel intentionModel) {
		List<IntentionModel> intentionModelList = intentionModelRpcService.selectIntentionCustomerList(intentionModel);
		Map<String, Object> customerInfo = null;
		for (IntentionModel model : intentionModelList) {
			Intention intention = model.getIntention();
			if (intention != null) {
				CustomerShop customerShop = intention.getCustomerShop();
				if (customerShop != null) {
					Customer customer = customerShop.getCustomer();
					if (customer != null) {
						customerInfo = new HashMap<>();
						customerInfo.put("customerNickName", customer.getCustomerNickname());
						customerInfo.put("customerHeadImage", customer.getCustomerHeadImage());
						customerInfo.put("customerMobile", intention.getCustomerMobile());
						customerInfo.put("createTime", intention.getCreateTime());
						customerInfo.put("customerShopId", customerShop.getCustomerShopId());
						customerList.add(customerInfo);
					}
				}
			}
		}
	}

}

